using System.Collections.Generic;

namespace Sinacor.Servico.Bovespa.Contabil.Service.ServiceImplementation.Translator.BusinessEntityToDataContract
{
    public class DespesaNota 
    {
        public DespesaNota() { }

        public DataContract.Response.DespesaNotaResponse ToDespesaNotaResponse(BusinessEntity.DespesaNota entity)
        {
            DataContract.Response.DespesaNotaResponse to = new Sinacor.Servico.Bovespa.Contabil.Service.DataContract.Response.DespesaNotaResponse();
            to.BaseDespesa = (DataContract.Enum.TipoBaseDespesa) entity.BaseDespesa;
            to.Codigo = entity.Codigo;

            if (entity.EventoContabil != null) 
            {
                to.EventoContabil = new Sinacor.Servico.Bovespa.Contabil.Service.DataContract.Response.EventoContabilResponse();
                to.EventoContabil.Codigo = entity.EventoContabil.Codigo;
                to.EventoContabil.Descricao = entity.EventoContabil.Descricao;
            }

            to.IncideIrrf = entity.IncideIrrf;
            to.PercentualDespesa = entity.PercentualDespesa;
            to.PregaoFinal = entity.PregaoFinal;
            to.PregaoInicial = entity.PregaoInicial;
            to.ValorMaximo = entity.ValorMaximo;
            to.ValorMinimo = entity.ValorMinimo; 
			return to;
		}

		public List<DataContract.Response.DespesaNotaResponse> ToDespesaNotaResponse(List<BusinessEntity.DespesaNota> entityList)
        {
            List<DataContract.Response.DespesaNotaResponse> to = new List<Sinacor.Servico.Bovespa.Contabil.Service.DataContract.Response.DespesaNotaResponse>();
            foreach (BusinessEntity.DespesaNota item in entityList)
            {
                to.Add(ToDespesaNotaResponse(item));
            }
			return to;
		}
	}
}